<template>
  <div class="navbar">
    <van-nav-bar
      :title="title"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
  </div>
</template>

<script lang="ts" setup>
import { useRouter, useRoute } from 'vue-router'
import { computed } from 'vue'

// 调用 useRouter() 函数，就可以获取到路由对象实例
const router = useRouter()
// 当前路由信息
const route = useRoute()
// 当前页面的标题信息: 根据当前激活的路由信息获取 meta 元数据中配置的 title
const title:any = computed(() => route.meta?.title ?? '默认标题')
const onClickLeft = () => router.back()
</script>

<style scoped>

</style>
